var a = getApp();

Page({
    data: {
        currentTab: 0,
        year: "",
        maxYear: "",
        minYear: "",
        weekIntegral: "-",
        todayIntegral: "-",
        citySort: "",
        cityText: "",
        monthSchedule: "-",
        yearSchedule: "-",
        sortText: "",
        listData: ""
    },
    loadData: function(t) {
        var e = this;
        a.network.post({
            url: 0 == e.data.currentTab ? a.url.getMeDataSchedule : a.url.getMeDataIncome,
            params: {
                year: e.data.year
            },
            before: function() {
                wx.showLoading({
                    title: "正在加载"
                });
            },
            success: function(t) {
                wx.hideLoading(), 1 == t.data.result ? e.setData({
                    listData: 0 == e.data.currentTab ? t.data.data.schedules : t.data.data.incomes,
                    minYear: t.data.data.minYear,
                    maxYear: t.data.data.maxYear,
                    weekIntegral: t.data.data.weekIntegral ? t.data.data.weekIntegral : e.data.weekIntegral,
                    todayIntegral: t.data.data.todayIntegral ? t.data.data.todayIntegral : e.data.todayIntegral,
                    citySort: t.data.data.citySort ? t.data.data.citySort : e.data.citySort,
                    cityText: t.data.data.cityText ? t.data.data.cityText : e.data.cityText,
                    monthSchedule: 0 == e.data.currentTab ? t.data.data.monthSchedule : t.data.data.monthIncome,
                    yearSchedule: 0 == e.data.currentTab ? t.data.data.yearSchedule : t.data.data.yearIncome,
                    sortText: t.data.data.sortText
                }) : a.util.showToast(t.data.message);
            },
            fail: function() {
                wx.hideLoading(), a.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading();
            }
        });
    },
    onLoad: function(a) {
        var t = new Date().getFullYear();
        this.setData({
            year: t
        }), wx.setNavigationBarTitle({
            title: this.data.year + "年单量总览"
        }), this.loadData();
    },
    clickLast: function(a) {
        this.data.year <= this.data.minYear ? wx.showModal({
            title: "提示",
            content: "暂无法统计" + this.data.minYear + "年之前的数据",
            showCancel: !1
        }) : (this.setData({
            year: this.data.year - 1
        }), wx.setNavigationBarTitle({
            title: this.data.year + (0 == this.data.currentTab ? "年单量总览" : "年收入总览")
        }), this.loadData());
    },
    clickNext: function(a) {
        this.data.year >= this.data.maxYear ? wx.showModal({
            title: "提示",
            content: "暂无法统计" + this.data.maxYear + "年之后的数据",
            showCancel: !1
        }) : (this.setData({
            year: this.data.year + 1
        }), wx.setNavigationBarTitle({
            title: this.data.year + (0 == this.data.currentTab ? "年单量总览" : "年收入总览")
        }), this.loadData());
    },
    clickSegment0: function(a) {
        this.setData({
            currentTab: 0,
            monthSchedule: "-",
            yearSchedule: "-"
        }), wx.setNavigationBarTitle({
            title: this.data.year + "年单量总览"
        }), this.loadData();
    },
    clickSegment1: function(a) {
        this.setData({
            currentTab: 1,
            monthSchedule: "-",
            yearSchedule: "-"
        }), wx.setNavigationBarTitle({
            title: this.data.year + "年收入总览"
        }), this.loadData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});